package com.sg.hms.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.sg.hms.Model.Role;
import com.sg.hms.Service.FoodService;
import com.sg.hms.ServiceImpl.FoodServiceImpl;
/**
 * 
 * @author 张杨
 *
 */
public class DeleteFoodController extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession session=req.getSession();
		FoodService fService=new FoodServiceImpl();
		Role role=(Role) session.getAttribute("currentrole");
		int rid=role.getRoleId();
		String foId[]=req.getParameterValues("fid");
		for (String f : foId) {	
			//System.out.println(f);
			fService.deleteFood(rid, Integer.parseInt(f));
		}
		req.getRequestDispatcher("foodManage").forward(req, resp);
	}
	
}
